<template>
     <view class="video_play">
    <image :src="videoObj.img"></image>
    <!-- 工具栏开始 -->
    <view class="video_tool">
      <view @click="hanleMuted" :class="['iconfont',isMuted?'iconjingyin':'iconshengyin']"></view>
      <view class="iconfont iconzhuanfa">
        <button open-type="share"></button>
      </view>
    </view>
    <!-- 工具栏结束 -->
    <!-- 视频开始 -->
    <view class="video">
      <video :muted="isMuted" objectFit="fill" :src="videoObj.video"></video>
    </view>
    <!-- 视频结束 -->
    <!-- 下载按钮开始 -->
    <view @click="handleDownload" class="download">
      <view class="btn">下载高清</view>
    </view>
    <!-- 下载按钮结束 -->
  </view>    
</template>

<script>
    export default {
        data() {
            return {
                videoObj:{},
                isMuted:false
            }
        },
        onLoad(){
            this.videoObj=getApp().globalData.video
        },
        methods:{
            hanleMuted(){
                this.isMuted=!this.isMuted
            },
           async handleDownload(){
               await uni.showLoading({
                   title:"下载中",
               })
               const { tempFilePath } =(await uni.downloadFile({url:this.videoObj.video}))[1]
               await uni.saveVideoToPhotosAlbum({
                   filePath:tempFilePath
               })
               uni.hideLoading()
              await uni.showToast({
                   title:"下载完成",
               })
            }
        }
    }
</script>

<style lang="scss" scoped>
.video_play {
  image {
    width: 100vw;
    height: 100vh;
    position: absolute;
    // 滤镜高斯模糊
    filter: blur(20px);
    z-index: -1;
  }
  .video_tool {
    display: flex;
    height: 80rpx;
    justify-content: flex-end;

    .iconfont {
      width: 80rpx;
      color: #fff;
      font-size: 50rpx;
      border-radius: 50%;
      background-color: rgba(0,0,0,.5);
      display: flex;
      justify-content: center;
      align-items: center;
      margin-right: 20rpx;
    }
    .iconzhuanfa {
      position: relative;
      button {
        position: absolute;
        width: 100%;
        height: 100%;
        opacity: 0;
      }
    }
  }

  .video {
    display: flex;
    justify-content: center;
    video {
      width: 360rpx;
      height: 600rpx;
    }
  }

  .download {
    display: flex;
    justify-content: center;
    margin-top: 30rpx;
    .btn {
      width: 360rpx;
      height: 80rpx;
      border-radius: 40rpx;
      background-color: rgba(0,0,0,.6);
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
      border: 1rpx solid #fff;
    }
  }
}
</style>